﻿using DAL;
using DbEntity;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Commen;

namespace AyaWo.WinForm
{
    public partial class MainForm : Form
    {
        public MainForm()
        {
            InitializeComponent();
            this.skinEngine1.SkinFile = "DeepCyan.ssk";
            dataGridView1.DataSource = SpiderContentService.ShoudSoLists();
        }

        private void btn_Service_Click(object sender, EventArgs e)
        {
             //new WinService.SplerDo().Doto();
            // new WinService.SoDo().ToDo(); 
           // new WinService.TonbuDo().ToDo();
            // new WinService.PanGuFenCi().ToDo();


            ServForm sf = new WinForm.ServForm();
            sf.ShowDialog();
        }

        private void btn_keySave_Click(object sender, EventArgs e)
        {
            if (lab_ID.Text.IsNullOrWhiteSpace())
                return;
            if (txt_key1.Text.IsNullOrWhiteSpace() && txt_key2.Text.IsNullOrWhiteSpace() && txt_key3.Text.IsNullOrWhiteSpace() && txt_key4.Text.IsNullOrWhiteSpace() && txt_key5.Text.IsNullOrWhiteSpace())
                return;
            SPFormModel spfm = new SPFormModel() { ID = lab_ID.Text, key1 = txt_key1.Text, key2 = txt_key2.Text, key3 = txt_key3.Text, key4 = txt_key4.Text, key5 = txt_key5.Text };
            SpiderContentService.UpKey12345s(spfm);
            dataGridView1.DataSource = SpiderContentService.ShoudSoLists();
        }

        private void dataGridView1_SelectionChanged(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedCells.Count != 0)
            {
                ////得到选中行的索引
                //int intRow = dataGridView1.SelectedCells[0].RowIndex;
                ////得到列的索引
                //int intColumn = dataGridView1.SelectedCells[0].ColumnIndex;

                //得到选中行某列的值
                string ID = dataGridView1.CurrentRow.Cells[0].Value == null ? null : dataGridView1.CurrentRow.Cells[0].Value.ToString();
                string title = dataGridView1.CurrentRow.Cells[1].Value == null ? null : dataGridView1.CurrentRow.Cells[1].Value.ToString();
                string key1 = dataGridView1.CurrentRow.Cells[2].Value == null ? null : dataGridView1.CurrentRow.Cells[2].Value.ToString();
                string key2 = dataGridView1.CurrentRow.Cells[3].Value == null ? null : dataGridView1.CurrentRow.Cells[3].Value.ToString();
                string key3 = dataGridView1.CurrentRow.Cells[4].Value == null ? null : dataGridView1.CurrentRow.Cells[4].Value.ToString();
                string key4 = dataGridView1.CurrentRow.Cells[5].Value == null ? null : dataGridView1.CurrentRow.Cells[5].Value.ToString();
                string key5 = dataGridView1.CurrentRow.Cells[6].Value == null ? null : dataGridView1.CurrentRow.Cells[6].Value.ToString();

                lab_ID.Text = ID;
                txt_title.Text = title;
                txt_key1.Text = key1;
                txt_key2.Text = key2;
                txt_key3.Text = key3;
                txt_key4.Text = key4;
                txt_key5.Text = key5;
            }
        }
    }
}
